
//--------------------------------------------------------------------//
//     此代码由T4模板自动生成										  //
//	   生成时间 2020-11-12 09:11:57 	                              //
//	   描述：应用接入配置表
//--------------------------------------------------------------------//

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using RayD.Core;

namespace RayD.Repository.Entites.SystemModule
{	
    [Table("BASE_APPCONFIG")]
	public class AppConfigEntity 
	{
        #region 实体成员
		/// <summary>
		/// 主键
		/// </summary>
		/// <returns></returns>
		[Key]
		[Column("B_ID")]
		public string B_Id { get; set; }
		/// <summary>
		/// 应用接入Id
		/// </summary>
		/// <returns></returns>
		[Column("B_APPID")]
		public string B_AppId { get; set; }
		/// <summary>
		/// 应用私钥
		/// </summary>
		/// <returns></returns>
		[Column("B_APPSECRET")]
		public string B_AppSecret { get; set; }
		/// <summary>
		/// 应用授权方
		/// </summary>
		/// <returns></returns>
		[Column("B_AUTHORIZER")]
		public string B_Authorizer { get; set; }
		/// <summary>
		/// 有效标志
		/// </summary>
		/// <returns></returns>
		[Column("B_ENABLEDMARK")]
		public EnabledMark? B_EnabledMark { get; set; }
		/// <summary>
		/// 删除标志(0:未删除 1:已删除)
		/// </summary>
		/// <returns></returns>
		[Column("B_DELETEMARK")]
		public DeleteMark? B_DeleteMark { get; set; }
		/// <summary>
		/// 备注
		/// </summary>
		/// <returns></returns>
		[Column("B_DESCRIPTION")]
		public string B_Description { get; set; }
		/// <summary>
		/// 创建日期
		/// </summary>
		/// <returns></returns>
		[Column("B_CREATEDATE")]
		public DateTime? B_CreateDate { get; set; }
		/// <summary>
		/// 创建用户主键
		/// </summary>
		/// <returns></returns>
		[Column("B_CREATEUSERID")]
		public string B_CreateUserId { get; set; }
		/// <summary>
		/// 创建用户
		/// </summary>
		/// <returns></returns>
		[Column("B_CREATEUSERNAME")]
		public string B_CreateUserName { get; set; }
		/// <summary>
		/// 修改日期
		/// </summary>
		/// <returns></returns>
		[Column("B_MODIFYDATE")]
		public DateTime? B_ModifyDate { get; set; }
		/// <summary>
		/// 修改用户主键
		/// </summary>
		/// <returns></returns>
		[Column("B_MODIFYUSERID")]
		public string B_ModifyUserId { get; set; }
		/// <summary>
		/// 修改用户
		/// </summary>
		/// <returns></returns>
		[Column("B_MODIFYUSERNAME")]
		public string B_ModifyUserName { get; set; }
		/// <summary>
		/// 删除日期
		/// </summary>
		/// <returns></returns>
		[Column("B_DELETEDATE")]
		public DateTime? B_DeleteDate { get; set; }
		/// <summary>
		/// 删除用户主键
		/// </summary>
		/// <returns></returns>
		[Column("B_DELETEUSERID")]
		public string B_DeleteUserId { get; set; }
		/// <summary>
		/// 删除用户
		/// </summary>
		/// <returns></returns>
		[Column("B_DELETEUSERNAME")]
		public string B_DeleteUserName { get; set; }
 
        #endregion
		
        #region 扩展操作
		/// <summary>
        /// 新增调用
        /// </summary>
        public void Create()
		{
			this.B_AppId = CommonHelper.RndCode(16);
			this.B_AppSecret = CommonHelper.RndCode(32);
			UserInfo userInfo = AuthenticationHelper.LoginUserInfo;
			this.B_Id = Guid.NewGuid().ToString();
			if (this.B_EnabledMark.IsEmpty())
			{
				this.B_EnabledMark = EnabledMark.Enabled;
			}
			this.B_DeleteMark = DeleteMark.Undeleted;
			this.B_CreateDate = DateTime.Now.ToCstTime();
			this.B_CreateUserId = userInfo.userId;
			this.B_CreateUserName = userInfo.realName;
			this.B_ModifyDate = DateTime.Now.ToCstTime();
			this.B_ModifyUserId = userInfo.userId;
			this.B_ModifyUserName = userInfo.realName;
		}
        /// <summary>
        /// 编辑调用
        /// </summary>
        public void Modify()
        {
			UserInfo userInfo = AuthenticationHelper.LoginUserInfo;
			this.B_ModifyDate = DateTime.Now.ToCstTime();
			this.B_ModifyUserId = userInfo.userId;
			this.B_ModifyUserName = userInfo.realName;
		}
		/// <summary>
		/// 虚拟删除调用
		/// </summary>
		public void Delete()
		{
			UserInfo userInfo = AuthenticationHelper.LoginUserInfo;
			this.B_EnabledMark = EnabledMark.Disabled;
			this.B_DeleteMark = DeleteMark.Deleted;
			this.B_DeleteDate = DateTime.Now.ToCstTime();
			this.B_DeleteUserId = userInfo.userId;
			this.B_DeleteUserName = userInfo.realName;
		}
		#endregion


	}
}
